home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 4 / FM Towns Free Software Collection 4 - Disc 1.iso / msdos / mcpr / cpruty.asm < prev    next >
Assembly Source File  |  1991-10-18  |  6KB  |  402 lines

  1.     page    95,132
  2. ;§∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞§
  3. ;§                                                                          §
  4. ;§            マルチカラム コンパクト プリント ユーティリティ            §
  5. ;§                                                                          §
  6. ;§   Multicolumn Compact PRint utility   MCPR.EXE  Ver1.40    §
  7. ;§   ~           ~       ~~                                                 §
  8. ;§              Copyright (C) by 福地 邦雄 1989-1990. All rights reserved.  §
  9. ;§∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞§
  10.     public    asctoint
  11.     public    inttoascs
  12.     public    inttoasc0
  13.     public    inttoascb
  14.     public    getarg
  15.     public    filelist
  16.     public    abort
  17.     public    errorno
  18.     public    dosstdout
  19. ;
  20. data    segment para    public    'DATA'
  21. ;
  22. errorno     dw        ?
  23. ;
  24. data    ends
  25. ;
  26. code    segment para    public    'CODE'
  27.     assume    cs:code,ds:data
  28. ;
  29. asctoint    proc
  30. ;
  31.     push    bx
  32.     push    cx
  33.     push    dx
  34.     xor    ax,ax
  35.     mov    cx,ax
  36.     mov    bx,10
  37. looplabel:
  38.     mov    cl,es:[di]
  39.     cmp    cl,'0'
  40.     jb    tointend
  41.     cmp    cl,'9'
  42.     ja    tointend
  43.     and    cl,0fh
  44.     mul    bx
  45.     add    ax,cx
  46.     inc    di
  47.     jmp    short    looplabel
  48. tointend:
  49.     test    ax,ax
  50.     pop    dx
  51.     pop    cx
  52.     pop    bx
  53.     ret
  54. ;
  55. asctoint    endp
  56. ;
  57. inttoascs   proc
  58. ;
  59.     push    cx
  60.     push    dx
  61.     cld
  62.     mov    cx,100
  63.     xor    dx,dx
  64.     div    cx
  65.     div    cl
  66.     test    al,al
  67.     jnz    allput5
  68.     test    ah,ah
  69.     jz    supressd
  70.     mov    al,ah
  71.     aam
  72.     test    ah,ah
  73.     jnz    allput4
  74.     add    al,'0'
  75.     stosb
  76.     jmp    short    allput3
  77. supressd:
  78.     mov    al,dl
  79.     aam
  80.     test    ah,ah
  81.     jnz    allput2
  82.     add    al,'0'
  83. lastone:
  84.     stosb
  85.     jmp    short    toascsend
  86. ;
  87. allput5:
  88.     add    al,'0'
  89.     stosb
  90.     mov    al,ah
  91.     aam
  92. allput4:
  93.     add    ax,'00'
  94.     xchg    ah,al
  95.     stosw
  96. allput3:
  97.     mov    al,dl
  98.     aam
  99. allput2:
  100.     add    ax,'00'
  101.     xchg    ah,al
  102.     stosw
  103. toascsend:
  104.     pop    dx
  105.     pop    cx
  106.     ret
  107. ;
  108. inttoascs   endp
  109. ;
  110. inttoasc0   proc
  111. ;
  112.     push    cx
  113.     push    dx
  114.     cld
  115.     mov    cx,100
  116.     xor    dx,dx
  117.     div    cx
  118.     div    cl
  119.     add    al,'0'
  120.     stosb
  121.     mov    al,ah
  122.     aam
  123.     add    ax,'00'
  124.     xchg    ah,al
  125.     stosw
  126.     mov    al,dl
  127.     aam
  128.     add    ax,'00'
  129.     xchg    ah,al
  130.     stosw
  131.     pop    dx
  132.     pop    cx
  133.     ret
  134. ;
  135. inttoasc0   endp
  136. ;
  137. inttoascb   proc
  138. ;
  139.     push    cx
  140.     push    dx
  141.     cld
  142.     mov    cx,100
  143.     xor    dx,dx
  144.     div    cx
  145.     div    cl
  146.     add    al,'0'
  147.     stosb
  148.     mov    al,ah
  149.     aam
  150.     add    ax,'00'
  151.     xchg    ah,al
  152.     stosw
  153.     mov    al,dl
  154.     aam
  155.     add    ax,'00'
  156.     xchg    ah,al
  157.     stosw
  158. ;
  159.     push    di
  160.     lea    di,[di-5]
  161.     mov    cx,4
  162. chgspcloop:
  163.     cmp    byte ptr es:[di],'0'
  164.     jne    chgend
  165.     mov    byte ptr es:[di],' '
  166.     inc    di
  167.     loop    chgspcloop
  168. chgend:
  169.     pop    di
  170.     pop    dx
  171.     pop    cx
  172.     ret
  173. ;
  174. inttoascb   endp
  175. ;
  176. strsvseg    equ     word ptr [bp+8]
  177. returnadr   equ     word ptr [bp+6]
  178. argvseg     equ     word ptr [bp+4]
  179. argvoff     equ     word ptr [bp+2]
  180. argcwrk     equ     word ptr [bp]
  181. ;
  182. getarg        proc
  183. ;
  184.     sub    sp,140
  185.     mov    bp,sp
  186.     mov    strsvseg,ss
  187.     mov    ax,[bp+140]
  188.     mov    returnadr,ax
  189.     mov    argvseg,es
  190.     xor    ax,ax
  191.     mov    argcwrk,ax
  192.     mov    cx,ax
  193.     mov    cl,ds:[80h]
  194.     mov    si,cx
  195.     inc    cx
  196.     mov    bx,81h
  197.     mov    byte ptr [si+bx],' '
  198. spaceloop:
  199.     cmp    byte ptr [bx],' '
  200.     je    nextchar
  201.     cmp    byte ptr [bx],09h
  202.     jne    spaceout
  203. nextchar:
  204.     inc    bx
  205.     loop    spaceloop
  206.     jmp    argend
  207. spaceout:
  208.     mov    es:[di],bx
  209.     lea    di,[di+4]
  210.     inc    word ptr argcwrk
  211. nospcloop:
  212.     inc    word ptr es:[di-2]
  213.     dec    cx
  214.     jcxz    stringend
  215.     inc    bx
  216.     cmp    byte ptr [bx],' '
  217.     je    stringend
  218.     cmp    byte ptr [bx],09h
  219.     je    stringend
  220.     jmp    short nospcloop
  221. stringend:
  222.     mov    byte ptr [bx],0
  223.     inc    bx
  224.     loop    spaceloop
  225. argend:
  226.     mov    argvoff,di
  227.     mov    ax,argcwrk
  228.     std
  229.     lea    di,[bp+141]
  230.     test    ax,ax
  231.     jz    noargs
  232. argsetloop:
  233.     sub    argvoff,4
  234.     mov    si,argvoff
  235.     mov    cx,es:[si+2]
  236.     mov    es:[si+2],ss
  237.     mov    si,es:[si]
  238.     add    si,cx
  239.     inc    cx
  240.     mov    es,strsvseg
  241.     rep movsb
  242.     les    si,[bp+2]        ;argvoff
  243.     mov    es:[si],di
  244.     inc    word ptr es:[si]
  245.     dec    argcwrk
  246.     jnz    argsetloop
  247. noargs:
  248.     dec    di
  249.     mov    si,returnadr
  250.     mov    ss:[di],si
  251.     mov    sp,di
  252.     test    ax,ax
  253.     ret
  254. ;
  255. getarg        endp
  256. ;
  257. copysiz equ    word ptr [bp]
  258. fnamsiz equ    word ptr [bp+2]
  259. saveds    equ    [bp+4]
  260. namstr    equ    0
  261. dtaadr    equ    4
  262. bufadr    equ    8
  263. bufoff    equ    8
  264. bufseg    equ    10
  265. bufsiz    equ    12
  266. ;
  267. filelist    proc
  268. ;
  269.     push    bp
  270.     sub    sp,6
  271.     mov    bp,sp
  272.     mov    saveds,ds
  273.     les    di,[bx].namstr
  274.     call    pathsep
  275.     mov    copysiz,cx
  276.     mov    ah,4eh
  277.     xor    cx,cx
  278.     lds    dx,[bx].namstr
  279.     int    21h
  280.     jc    notfound
  281. findloop:
  282.     mov    ds,saveds
  283.     les    di,[bx].dtaadr
  284.     mov    cx,13
  285.     xor    al,al
  286.     cld
  287.   repne scasb
  288.     sub    cx,13
  289.     neg    cx
  290.     mov    fnamsiz,cx
  291.     add    cx,copysiz
  292.     sub    [bx].bufsiz,cx
  293.     jae    existbuff
  294.     add    [bx].bufsiz,cx
  295.     jmp    short    srchout
  296. existbuff:
  297.     les    di,[bx].bufadr
  298.     lds    si,[bx].namstr
  299.     mov    cx,copysiz
  300.     rep movsb
  301.     mov    ds,saveds
  302.     lds    si,[bx].dtaadr
  303.     mov    cx,fnamsiz
  304.     rep movsb
  305.     mov    ds,saveds
  306.     mov    [bx].bufoff,di
  307. ;
  308.     mov    ah,4fh
  309.     lds    dx,[bx].namstr
  310.     xor    cx,cx
  311.     int    21h
  312.     jnc    findloop
  313. notfound:
  314.     mov    ds,saveds
  315. srchout:
  316.     add    sp,6
  317.     pop    bp
  318.     ret
  319. ;
  320. filelist    endp
  321. ;
  322. pathsep     proc
  323. ;
  324.     mov    cx,0ffffh
  325.     cld
  326.     xor    al,al
  327.     push    di
  328.   repne scasb
  329.     pop    di
  330.     not    cx
  331.     dec    cx
  332.     jz    nonames
  333. ;
  334.     push    cx
  335.     xor    dx,dx
  336. analysloop:
  337.     mov    al,es:[di]
  338.     inc    di
  339.     cmp    al,':'
  340.     je    findpathchar
  341.     cmp    al,'\'
  342.     je    findpathchar
  343.     cmp    al,81h
  344.     jb    nextanalys
  345.     cmp    al,0a0h
  346.     jb    knjchar
  347.     cmp    al,0e0h
  348.     jb    nextanalys
  349.     cmp    al,0fdh
  350.     jae    nextanalys
  351. knjchar:
  352.     inc    di
  353.     dec    cx
  354.     jz    analysend
  355.     jmp    short nextanalys
  356. findpathchar:
  357.     mov    dx,cx
  358. nextanalys:
  359.     loop    analysloop
  360. analysend:
  361.     pop    cx
  362.     test    dx,dx
  363.     jz    nochar
  364.     dec    dx
  365.     sub    cx,dx
  366. nonames:
  367.     ret
  368. ;
  369. nochar:
  370.     xor    cx,cx
  371.     ret
  372. ;
  373. pathsep     endp
  374. ;
  375. dosstdout   proc
  376. ;
  377.     mov    ah,40h
  378.     mov    bx,1
  379.     int    21h
  380.     jc    outerr
  381.     ret
  382. ;
  383. dosstdout   endp
  384. ;
  385. abort        proc
  386. ;
  387.     mov    ax,seg    data
  388.     mov    ds,ax
  389.     mov    ah,40h
  390.     mov    bx,1
  391.     int    21h
  392. ;
  393.     mov    ax,errorno
  394. outerr:
  395.     mov    ah,4ch
  396.     int    21h
  397. ;
  398. abort        endp
  399. ;
  400. code    ends
  401.     end
  402.